package exam.huawei;

import java.util.Scanner;

/**
 * @author chenhong
 * @version 1.0
 * @description TODO
 * @date 2023/4/10 14:05
 */
public class HJ5 {
}
class Main5 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) { // 注意 while 处理多个 case
            String hex_str = in.next();
            if(hex_str.charAt(0) == '0'){
                System.out.println(Integer.parseInt(hex_str.substring(2),16));
            }else{
                System.out.println(Integer.parseInt(hex_str,16));
            }
        }
    }
}